
package members;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;

public class UpdateMember {
    
    private String accountName;
    private String accountRealName;
    private String sex;
    private String tel;
    private String county;
    private String region;
    private String address;
    private String email;
    
    public UpdateMember() {
    }
    
    public String execute() throws Exception {
        
        HttpServletRequest request=ServletActionContext.getRequest();        
        HttpSession session=request.getSession();
        
        db.NWDB mydb=new db.NWDB();
        HashMap<String,Object> hm=mydb.getMemberInfoByAccount(session.getAttribute("LoginName").toString());
        
        this.setAccountName(session.getAttribute("LoginName").toString());
        this.setAccountRealName(hm.get("姓名").toString());
        this.setAddress(hm.get("地址").toString());
        this.setCounty(hm.get("縣市").toString());
        this.setEmail(hm.get("郵件").toString());
        this.setRegion(hm.get("鄉鎮區").toString());
        this.setSex(hm.get("性別").toString());
        this.setTel(hm.get("電話").toString());
        
        
        HashSet<members.OrderItem> order= new HashSet<members.OrderItem>();
        int memberid = (Integer)session.getAttribute("MemberID");  
        ArrayList<HashMap<String,Object>> list=mydb.getbookingInfo(memberid);
        
        for(int i = 0 ; i < list.size(); i ++)
        {
            members.OrderItem oi = new members.OrderItem();
            oi.setoID(list.get(i).get("訂單序號").toString());
            oi.setOstate(list.get(i).get("單據狀態").toString());
            oi.setoName(list.get(i).get("紮營者姓名").toString());
            oi.setoTel(list.get(i).get("紮營者連絡電話").toString());
            oi.setoTotalprice(list.get(i).get("總價").toString());
            oi.setoMoneytransferDate(list.get(i).get("匯款日期").toString());
            oi.setObtansferlast5code(list.get(i).get("匯款帳號末五碼").toString());
            oi.setObankID(list.get(i).get("銀行代碼").toString());
            order.add(oi);
        }
        
        mydb.dbClose();
        session.setAttribute("Order", order); 
        //session.setAttribute("iii", list.size());
        
        
        return "success";
        
    }

    /**
     * @return the accountName
     */
    public String getAccountName() {
        return accountName;
    }

    /**
     * @param accountName the accountName to set
     */
    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    /**
     * @return the accountRealName
     */
    public String getAccountRealName() {
        return accountRealName;
    }

    /**
     * @param accountRealName the accountRealName to set
     */
    public void setAccountRealName(String accountRealName) {
        this.accountRealName = accountRealName;
    }

    /**
     * @return the sex
     */
    public String getSex() {
        return sex;
    }

    /**
     * @param sex the sex to set
     */
    public void setSex(String sex) {
        this.sex = sex;
    }

    /**
     * @return the tel
     */
    public String getTel() {
        return tel;
    }

    /**
     * @param tel the tel to set
     */
    public void setTel(String tel) {
        this.tel = tel;
    }

    /**
     * @return the county
     */
    public String getCounty() {
        return county;
    }

    /**
     * @param county the county to set
     */
    public void setCounty(String county) {
        this.county = county;
    }

    /**
     * @return the region
     */
    public String getRegion() {
        return region;
    }

    /**
     * @param region the region to set
     */
    public void setRegion(String region) {
        this.region = region;
    }

    /**
     * @return the address
     */
    public String getAddress() {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(String address) {
        this.address = address;
    }

    /**
     * @return the email
     */
    public String getEmail() {
        return email;
    }

    /**
     * @param email the email to set
     */
    public void setEmail(String email) {
        this.email = email;
    }


    
}
